package Solution;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2023-01-20
 * Time: 16:24
 */

//https://leetcode.cn/problems/remove-duplicates-from-sorted-array/submissions/396452436/
class Solution3 {

    public static int removeDuplicates(int[] nums) {
        int slow = 0;
        int right = 0;
        for (right = 1; right < nums.length; right++) {
            if (nums[right] != nums[slow]) {
                slow++;
                nums[slow] = nums[right];
            }
        }
        return slow + 1;
    }
}
